abstract class Op {
    char ch;

    public Op() {}
    public Op(char ch) {
        this.ch = ch;
    }

    abstract public int op(int n1, int n2);
}

class Add extends Op {
    public Add() {
        super('+');
    }

    public int op(int n1, int n2) {
        return n1 + n2;
    }
}

class Sub extends Op {
    public Sub() {
        super('-');
    }

    public int op(int n1, int n2) {
        return n1 - n2;
    }
}

class Mul extends Op {
    public Mul() {
        super('*');
    }

    public int op(int n1, int n2) {
        return n1 * n2;
    }
}

class Div extends Op {
    public Div() {
        super('/');
    }

    public int op(int n1, int n2) {
        return n1 / n2;
    }
}

class Mod extends Op {
    public Mod() {
        super('%');
    }

    public int op(int n1, int n2) {
        return n1 % n2;
    }
}

class Power extends Op {
    public Power() {
        super('^');
    }

    public int op(int n1, int n2) {
        int num = n1;
        while (--n2 != 0) {
            num *= n1;
        }

        return num;
    }
}

public class OpTest {
    static public void test(Op o1, Op o2) {
        if (o2.op(o1.op(5, 3), 2) == 4)
            System.out.printf("(5 %c 3) %c 2 == 4\n", o1.ch, o2.ch);
    }

// (5 _ 3) _ 2 = 4
    static public void main(String [] args) {
        Op p[] = {new Add(), new Sub(), new Mul(),
                  new Div(), new Mod(), new Power()};

        for (int i = 0; i < p.length; ++i) {
            for (int j = 0; j < p.length; ++j) {
                test(p[i], p[j]);
            }
        }
    }
}
